<template>
    <section>
        <full-screen-dialog
            :title="titleMap[mode]"
            v-model="visible"
            :width="1200"
            destroy-on-close
            @closed="$emit('closed')"
        >
            <el-form :disabled="mode == 'Show'" ref="dialogForm" label-width="100px">
                <el-descriptions :column="4">
                    <el-descriptions-item label="下单日期">{{entityObj.storageOrderTime}}</el-descriptions-item>
                    <el-descriptions-item label="单据编号">{{entityObj.storageOrderCode}}</el-descriptions-item>
                    <el-descriptions-item label="客户">{{entityObj.storeName}}</el-descriptions-item>
                    <el-descriptions-item label="业务员">{{entityObj.salesman}}</el-descriptions-item>
                    <el-descriptions-item label="制单人">{{entityObj.documentsUser}}</el-descriptions-item>
                    <el-descriptions-item label="关联要货单">{{entityObj.applyOrderCode}}</el-descriptions-item>
                </el-descriptions>
                <el-table :data="[entityObj]" :border="true" style="width: 100%" show-summary>
                    <!-- <el-table-column label="修改记录">
                        <template #default="scope">
                            <el-button
                                v-if="scope.row.storageOrderLogs.length>0"
                                size="small"
                                @click="opChange(scope.row,scope.$index)"
                            >修改记录{{scope.row.storageOrderLogs&&scope.row.storageOrderLogs.length>0?"/"+scope.row.storageOrderLogs.length:""}}</el-button>
                            <div v-else>无</div>
                        </template>
                    </el-table-column> -->
                    <el-table-column label="物料名称" width="150" prop="materialName" ></el-table-column>
                    <el-table-column label="物料规格" width="150" prop="materialSpecs" ></el-table-column>
                    <el-table-column label="数量" width="100" prop="qty" ></el-table-column>
                    <el-table-column label="单位" width="150" prop="unitName" ></el-table-column>
                    <el-table-column label="押金费">
                        <template #default="scope">
                            <el-input
                                v-model="scope.row.totalAmount"
                                style="width: 100%"
                                :step="1"
                                controls-position="right"
                            ></el-input>
                        </template>
                    </el-table-column>
                   

                    <el-table-column label="备注">
                        <template #default="scope">
                            <el-input v-model="scope.row.remarks" />
                        </template>
                    </el-table-column>
                </el-table>
            </el-form>

            <!-- <el-form :model="entityObj" :rules="rules" :disabled="mode == 'Show'" ref="dialogForm" label-width="100px">

            </el-form>-->
            <template #footer>
                <div style="text-align: center;">
                    <el-button @click="visible = false">关 闭</el-button>
                    <el-button type="primary" v-if="mode != 'Show'" @click="submit()">保存</el-button>
                </div>
            </template>
        </full-screen-dialog>
    </section>
</template>

<script>
import tool from "@/utils/tool";
export default {
    emits: ["success", "closed"],
    data() {
        return {
            mode: "Check",
            titleMap: {
                Check: "核对",
                Show: "物料明细",
            },
            visible: false,
            entityObj: {},
            rules: {},
            listData: [],
        };
    },
    methods: {
        //显示=
        open(mode = "Check") {
            this.mode = mode;
            this.visible = true;
            return this;
        },
        //表单注入数据
        async setData(data) {
            console.log(data);
            try {
                this.entityObj = data;
            } catch (error) {
                this.loading = false;
                return false;
            }
        },
        async submit() {
            let obj = {};
            obj.storageOrderId = this.entityObj.storageOrderId;
            obj.price = this.entityObj.price;
            obj.qty = this.entityObj.qty;
            obj.totalAmount = this.entityObj.totalAmount;
            obj.remarks = this.entityObj.remarks;

            const returnValue = await this.$API.auth.PostProcessApi.post(
                "storage-order/check",
                obj
            );
            if (returnValue.status == 200) {
                this.$message.success(returnValue.msg);
                this.$emit("fatherMethod");
                this.visible = false;
            } else {
                this.$message.error("操作失败:" + returnValue.msg);
            }
        },
    },
};
</script>

<style scoped>
</style>
